<template>
<div class="Acc_table" >
  <!-- 左上框 -->
  <div class="Acc_sel">
      <div class="Acc_sel_1">
        <select>
          <option value ="1_1">实验室中心主任</option>
          <option value ="1_2">学生负责人</option>
          <option value="1_3">借用部门负责人</option>
          <option value="1_4">实验室借用管理员</option>
          <option value="1_5">实验室中心主任</option>
        </select>
     </div>
      
  </div>

<!-- 右上框 -->
  <el-autocomplete
  v-model="state"
  :fetch-suggestions="querySearchAsync"
  placeholder="请输入内容"
  @select="handleSelect"
  
></el-autocomplete>
  <el-row>
    <el-button type="primary">
      <i class="el-icon-search"></i>
      搜索
    </el-button>
  </el-row>
  

  <!-- 表单 -->
  <el-table
    :data="tableData"
    style="width: 100%">
    <el-table-column
      label="姓名"
      align="center"
      >
      <template slot-scope="scope">
        <span style="margin-left: 10px">{{ scope.row.name }}</span>
      </template>
    </el-table-column>

    <el-table-column
      label="职位"
      align="center"
      >
      <div class="Acc_sel_1">
        <select>
          <option value ="1_1">实验室中心主任</option>
          <option value ="1_2">学生负责人</option>
          <option value="1_3">借用部门负责人</option>
          <option value="1_4">实验室借用管理员</option>
          <option value="1_5">实验室中心主任</option>
        </select>
     </div>
    </el-table-column>

    <el-table-column
      label="工号"
      align="center"
     >
      <template slot-scope="scope"> 
        <span style="margin-left: 10px">{{ scope.row.jobNumber }}</span>
      </template>
    </el-table-column>

     <el-table-column
      label="邮箱"
      align="center"
      width="250%"
     >
      <template slot-scope="scope">     
        <span style="margin-left: 10px">{{ scope.row.e_mail }}</span>
      </template>
    </el-table-column>

      <el-table-column
      label="电话"
      align="center"
     >
      <template slot-scope="scope">
        <span style="margin-left: 10px">{{ scope.row.phone }}</span>
      </template>
    </el-table-column>

      <el-table-column
      label="密码"
      align="center"
     >
      <template slot-scope="scope">
    <el-button
          size="mini"
          type="warning"
          @click="handleDelete(scope.$index, scope.row)">修改
        </el-button>
      </template>
    </el-table-column>

     <el-table-column label="操作" width="250%">
      <template slot-scope="scope">
        <el-switch
          v-model="scope.row.value"
          active-color="#13ce66"
          inactive-color="#ff4949">
        </el-switch>
        <el-button
          size="mini"
          type="primary"
          @click="handleDelete(scope.$index, scope.row)">修改
        </el-button>
      </template>
    </el-table-column>
    
  </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage4"
      :page-sizes="[100, 200, 300, 400]"
      :page-size="100"
      layout="total, sizes, prev, pager, next, jumper"
      :total="400">
    </el-pagination>
  </div>
</template>

<script>
export default {
     data() {
      return {
        // switch
        
        // 搜索
        restaurants: [],
        state: '',
        timeout:  null,

      // 表单
         tableData: [{
          name:'肖二拾',
          position: '摸鱼',
          jobNumber: '20330320620',
          e_mail: '1191928508@qq.com',
          phone:'13408098464',
          value: true,
        }, {
          name:'肖二拾',
          position: '摸鱼',
          jobNumber: '20330320620',
          e_mail: '1191928508@qq.com',
          phone:'13408098464',
          value: true,
        },],
      };
    },
    methods: {
      // 表单
      handleEdit(index, row) {
        console.log(index, row);
      },
      handleDelete(index, row) {
        console.log(index, row);
      },

      // 搜索
      loadAll() {
        return [
         { "value": "速记黄焖鸡米饭", "address": "上海市长宁区北新泾街道金钟路180号1层01号摊位" },
          { "value": "红辣椒麻辣烫", "address": "上海市长宁区天山西路492号" },
          { "value": "(小杨生煎)西郊百联餐厅", "address": "长宁区仙霞西路88号百联2楼" },
          { "value": "阳阳麻辣烫", "address": "天山西路389号" },
          { "value": "南拳妈妈龙虾盖浇饭", "address": "普陀区金沙江路1699号鑫乐惠美食广场A13" }
        ];
      },
      querySearchAsync(queryString, cb) {
        var restaurants = this.restaurants;
        var results = queryString ? restaurants.filter(this.createStateFilter(queryString)) : restaurants;

        clearTimeout(this.timeout);
        this.timeout = setTimeout(() => {
          cb(results);
        }, 3000 * Math.random());
      },
      createStateFilter(queryString) {
        return (state) => {
          return (state.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
        };
      },
      handleSelect(item) {
        console.log(item);
      }
    },
    mounted() {
      this.restaurants = this.loadAll();
    },
   
    }
  
</script>

<style scoped>
.Acc_table {
  position: relative;
  height: 100%;
  background-color: #fff;
} 
.el-table-column {
  background-color: rgb(201, 29, 29);
}
.el-row {
  display: inline-block;
  margin-left: 20px;
}


.el-autocomplete {
  display: inline-block;
  margin-left: 500px;
  margin-bottom: 20px;
  margin-top: 20px;
}
.el-pagination
 {
  margin-top: 40%;
}
.Acc_sel {
  float: left;
  margin-top: 2%;
  margin-left: 3%;
}
.FormExa_sel_1 ,
.FormExa_sel_2
{
  
  display: inline-block;
  margin-right: 20px;
}
.el-switch  {
  margin-right: 20px;
}
select {
  width: 140px;
  height: 35px;
}
 
</style>